﻿@model IEnumerable<WebVideo.EntityReport_PoductPoint>
@{
    ViewBag.Title = "Index";
    Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
}
<script src="@Url.Content("~/Content/cssAdmin/js/plugins/jquery-1.7.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Content/cssAdmin/js/plugins/jquery-ui-1.8.16.custom.min.js")" type="text/javascript"></script>

<script type="text/javascript">
    $(function () {
        $('.stdtable a.delete').click(function () {
            var c = confirm('Continue delete?');
            if (c) jQuery(this).parents('tr').fadeOut(function () {

                var id = $(this).closest('tr').find('td:eq(0)').text();
                var getURL = '@Url.Action("Delete", "ReportProductPoint")';

                $.get(getURL, { "id": id }, function (data) {
                    if (data == "error") //error
                    {
                        $('#nofError').show();
                        $('#nofSuccess').hide();
                        $('#msgNofError').text("Cannot Delete Record");
                    }
                    else {
                        jQuery(this).remove();
                        $('#nofError').hide();
                        $('#nofSuccess').show();
                        $('#msgNofSuccess').text("Delete Record Ok");
                    }
                });
            });
            return false;
        });
    });
</script>
<ul class="maintabmenu multipletabmenu">
    <li class="current"><a href="@Url.Action("Index", "ReportPoductPoint")" >Index</a></li>
    <li class="current"><a href="#" onclick="return saveExcel();" >Xuất báo cáo đổi sản phẩm khác</a></li>
</ul>
<!--maintabmenu-->
<div class="notification msgsuccess" style="display: none" id="nofSuccess">
    <a class="close"></a>
    <p id="msgNofSuccess">This is a success message.</p>
</div>
<!-- notification msgsuccess -->
<div class="notification msgerror" style="display: none" id="nofError">
    <a class="close"></a>
    <p id="msgNofError">This is an error message.</p>
</div>
<!-- notification msgerror -->
<div class="contenttitle">
    <h2 class="form"><span>List Report</span></h2>
</div>
<!--contenttitle-->
<table cellpadding="0" cellspacing="0" border="0" class="stdtable" id="dyntable">
    <colgroup>
        <col class="con0" />
        <col class="con1" />
        <col class="con0" />
        <col class="con1" />
        <col class="con0" />
        <col class="con1" />
        <col class="con0" />
        <col class="con1" />
        <col class="con0" />
        <col class="con1" />
    </colgroup>
    <thead>
        <tr>
             <th class="head0">Id</th>
            <th class="head1">UserName</th>
            <th class="head1">Tên sản phẩm</th>
            <th class="head0">Mệnh giá</th>
            <th class="head1">Số Điện Thoại</th>
            <th class="head0">Trạng thái</th>
            <th class="head1">Date</th>
            <th class="head1">Hành Động</th>
        </tr>
    </thead>
    <tfoot>
        <tr>
            <th class="head0">Id</th>
            <th class="head1">UserName</th>
            <th class="head1">Tên sản phẩm</th>
            <th class="head0">Mệnh giá</th>
            <th class="head1">Số Điện Thoại</th>
            <th class="head0">Trạng thái</th>
            <th class="head1">Date</th>
            <th class="head1">Hành Động</th>
        </tr>
    </tfoot>
    <tbody>
        @{
            
            foreach (var item in Model)
            {
                
            <tr class="gradeX">
                 <td>                 
                    @Html.DisplayFor(modelitem => item.Id)
                </td>
                <td>                 
                    @Html.ActionLink(item.UserName, "Edit", "User", new { US= item.UserName},null)
                </td>
                <td>
                    @Html.DisplayFor(modelitem => item.EntityProduct_Point.Name)
                </td>
                 <td>
                    @Html.DisplayFor(modelitem => item.EntityProduct_Point.Value) K
                </td>
                <td>
                    @Html.DisplayFor(modelitem => item.PhoneNumber)
                </td>
                <td>
                     @{
                        if (@Html.DisplayFor(modelitem => item.Status).ToString() == "1")
                        {
                                <span class="field">Chưa đổi</span>
                        }
                        else
                        {
                                <span class="field" style="color: red;">Đã đổi</span>
                        }   
                    }
                </td>
                <td>
                    @Html.DisplayFor(modelitem => item.Date)
                </td>
                 <td class="eddelete" >
                      @{
                            if (@Html.DisplayFor(modelitem => item.Status).ToString() == "1")
                            {
                                    @Html.ActionLink(" ", "Ban", new { Id = @item.Id, l = 2}, new { @class = "ban", title="Đổi xong"  })
                            }
                            else
                            {
                                    @Html.ActionLink(" ", "Ban", new { Id = @item.Id, l = 1}, new { @class = "edit", title="Chưa đổi"  })     
                                     <a href="#" class="delete" title="Delete" , onclick='DeleteRecord("@item.Id ")' ></a> 
                            }  
                           
                        }
                </td>    
            </tr> 
            }                       
        }
    </tbody>
</table>
<script type="text/javascript"  src="@Url.Content("~/Content/cssAdmin/js/custom/tables.js")" ></script>
<script type="text/javascript"  src="@Url.Content("~/Content/cssAdmin/js/plugins/jquery.dataTables.min.js")" ></script>


<script>

    $(document).ready(function () {
        var table = jQuery("#dyntable").dataTable({
            "bDestroy": true,
            "bProcessing": true,
            "sPaginationType": "full_numbers",
            "aaSorting": [[6, "desc"]]
        });
    });

    function saveExcel() {
        var postUrl = '@Url.Action("saveExcel", "ReportProductPoint")';
           $.post(postUrl, function (data) {
               var strTemp = '@Url.Content("~/Content/!!!")';
             strTemp = strTemp.replace("!!!", data);
             window.location = strTemp;
         });
         return false;
         }
</script>